import { S } from '../../s';
import { IPSAppCodeList } from '../../app/codelist/ipsapp-code-list';
import { IPSAppDEDataExportItem } from '../../app/dataentity/ipsapp-dedata-export-item';
import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { IPSDEDataExportItem } from './ipsdedata-export-item';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEDataExportItemImpl
  extends PSModelObjectImpl
  implements IPSDEDataExportItem, IPSAppDEDataExportItem
{
  get align(): 'LEFT' | 'CENTER' | 'RIGHT' {
    return this.M.align;
  }

  protected cappslanguageres: IPSLanguageRes;
  getCapPSLanguageRes(): IPSLanguageRes | null {
    return (
      this.cappslanguageres ||
      (this.cappslanguageres = this.fillObjectModel(
        S._276,
        this.M.getCapPSLanguageRes,
        S._2a8,
      ) as IPSLanguageRes)
    );
  }

  get caption(): string {
    return this.M.caption;
  }

  get defaultValue(): IModel {
    return this.M.defaultValue;
  }

  get format(): string {
    return this.M.format;
  }

  protected psappdefield: IPSAppDEField;
  getPSAppDEField(): IPSAppDEField | null {
    if (this.psappdefield != null) return this.psappdefield;
    const value = this.M.getPSAppDEField;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getParentPSModelObject(
      S._f,
    ) as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.psappdefield = ipsappdataentity.findPSAppDEField(value);
    }
    return this.psappdefield;
  }

  protected pscodelist: IPSAppCodeList;
  getPSCodeList(): IPSAppCodeList | null {
    return (
      this.pscodelist ||
      (this.pscodelist = this.fillObjectModel(
        S._8,
        this.M.getPSCodeList,
        S._2e5,
      ) as IPSAppCodeList)
    );
  }

  get privilegeId(): string {
    return this.M.privilegeId;
  }

  get hidden(): boolean {
    return this.M.hidden != null ? this.M.hidden : false;
  }
  get cls(): string {
    return 'PSDEDataExportItemImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._1d4 || cls == S._1d5) return true;
    return super.instanceof(cls);
  }
}
